package com.example.demo.create.builder;

/**
 * @Desc:
 * @Author zzz
 * @Date 2021/2/20
 * @Version V1.0
 */
public class UserBuilder {

    private String name;
    private int age;
    private String gender;


    public static UserBuilder builder() {
        return new UserBuilder();
    }

    public UserBuilder name(String name) {
        this.name = name;
        return this;
    }

    public UserBuilder age(int age) {
        this.age = age;
        return this;
    }

    public UserBuilder gender(String gender) {
        this.gender = gender;
        return this;
    }

    public User build() {
        return new User(this.name, this.age, this.gender);
    }

    public static void main(String[] args) {
        User user = UserBuilder.builder().name("ZS").age(18).gender("male").build();
        System.out.println(user);
    }

}
